# 代码所有：cxw
# 开发时间：2021/11/13 23:09


# import json
# files="names.json"
# name=input("请输入你的名字")
# with open(files,"w") as file_oj:
#     json.dump(name,file_oj)
# with open(files) as file_obj:
#     username=json.load(file_obj)
# print("我知道你最喜欢的数字是",username)

#改进版
import json
def num_already_greet():
    try:
        file = "666.json"
        with open(file) as file_ob:
            likesnum = json.load(file_ob)
    except FileNotFoundError:
        return None
    else:
        return likesnum
def greet_new_users():
    filename="666.json"
    new_num=input("请输入你喜欢的数字：")
    with open(filename,"w") as files:
        json.dump(new_num,files)
    return new_num
def greet_no_num():
    likenum=num_already_greet()
    if likenum:
        print("你喜欢的数字又出现了",likenum)
    else:
        likesnum=greet_new_users()
        print("你喜欢的数字是 ",likesnum)
greet_no_num()

